package edu.eas.student.controller;

import cn.hutool.core.collection.CollUtil;
import edu.eas.common.constant.AuthConstant;
import edu.eas.common.domain.UserDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author cql
 */
@RestController
@Api(tags = "StudentController", description = "学生管理")
@RequestMapping("/student")
public class StudentController {

    /**
     * 根据用户名获取通用用户信息
     *
     * @param username
     * @return
     */
    @ApiOperation("根据用户名获取通用用户信息")
    @GetMapping(value = "/loadByUsername")
    public UserDto loadUserByUsername(@RequestParam String username) {
        UserDto userDto = new UserDto();
        userDto.setUserType(AuthConstant.USER_TYPE_STUDENT);
        userDto.setId(1L);
        userDto.setUsername(username);
        userDto.setPassword("$2a$10$wjNHck1yDTlX3n2IbI7tu.OocI9NyrspCzm/gpzxeRU1.oMV7E6Yi");
        userDto.setRoles(CollUtil.toList("student"));
        userDto.setStatus(1);
        return userDto;
    }

}
